package com.sfac.springboot.modules.common.controller;

import com.sfac.springboot.modules.common.service.ImageService;
import com.sfac.springboot.modules.common.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author jzq
 * @date 2022/8/23 10:51
 */
@SuppressWarnings({"all"})
@RestController
@RequestMapping("/api")
public class ImageController {

    @Autowired
    private ImageService imageService;


    /**
     * localhost/api/image/profileBig   ---post
     *
     * @param file
     * @param imageTypeName
     * @return
     */
    @PostMapping(value = "/image/{imageTypeName}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    public Result<String> uploadImage(@RequestParam MultipartFile file,
                                      @PathVariable String imageTypeName) {
        return imageService.uploadImage(file, imageTypeName);
    }

}
